/* Sentinel - IRC Statistical and Operator Services
** match.c - IRCnet derived match() and family
**
** Copyright W. Campbell and others.  See README for more details
** Some code Copyright: Jonathan George, Kai Seidler, ircd-hybrid Team,
**                      IRCnet IRCD developers.
**
** $Id: match.h,v 1.3 2003/11/20 13:41:22 wcampbel Exp $
*/

#ifndef MATCH_H
#define MATCH_H

#define MATCH_RFC1459	0
#define MATCH_ASCII	1

/* XXX mmmmmmmmmm */
#define IsLower(c)  ((unsigned char)(c) > 0x5f)
#define IsUpper(c)  ((unsigned char)(c) < 0x60)

#define C_ALPHA	0x00000001
#define C_DIGIT	0x00000002

extern const unsigned int charattrs[];

#define IsAlpha(c)	(charattrs[(unsigned char) (c)] & C_ALPHA)
#define IsDigit(c)	(charattrs[(unsigned char) (c)] & C_DIGIT)
#define IsAlphaNum(c)	(IsAlpha((c)) || IsDigit((c)))
#define IsNon(c)	(!IsAlphaNum((c)))

extern const unsigned char ToLowerTab[];
extern const unsigned char ToUpperTab[];

void set_match_mapping(int);

int ToLower(int);
int ToUpper(int);

int irccmp(char *, char *);
int irccasecmp(char *, char *);
int ircncmp(char *, char *, int);
int ircncasecmp(char *, char *, int);

int match(char *, char *);
char *collapse(char *);

#endif
